type AjaxImportantDeviceSaveOrUpdateParams = any

export const defaultDeviceForm: AjaxImportantDeviceSaveOrUpdateParams = {
  tenantId: null as any,
  equipmentName: '',
  equipmentType: '',
  orderNum: 0,
  model: '',
  power: '',
  keyTechnicalData: '',
  loadRate: 0,
  runTime: 0,
  repairNum: 0,
  status: 0,
  isEliminate: 0,
  planUpdateTime: '',
  project: '',
  index: '',
  notes: '',
}
function validateNumber(_: any, value: string, cb: any) {
  value?.trim?.()
  if (!value) {
    cb()
  }
  const regex = /^\d+$/
  const isValid = regex.test(value)
  if (!isValid) {
    cb(new Error('请输入数字！'))
  }
  cb()
}
export const deviceFormRules = {
  equipmentName: [
    {
      required: true,
      message: '名称不能为空',
      trigger: 'blur',
    },
  ],
  targetName: [
    {
      required: true,
      message: '名称不能为空',
      trigger: 'blur',
    },
  ],
  targetUnit: [
    {
      required: true,
      message: '单位不能为空',
      trigger: 'blur',
    },
  ],
  runTime: [{ validator: validateNumber, trigger: 'blur' }],
  loadRate: [{ validator: validateNumber, trigger: 'blur' }],
  benchmarkValue: [],
  enterpriseValue: [],
  used: [],
  life: [],
}
